*get data
clear
import delimited "/Users/caseyklofstad/Library/CloudStorage/Dropbox/NSF Conspiracy Theory Surveys/casey 2018 survey/Voices and Mixed-Sex Elections Survey_July 25, 2018_11.16_WORKING_DATA.csv"

*keep vars needed for analysis
keep q2 q3 q4 q5 q6 q8 q7 q67 q83 q85 q87 q84 q86 q88 q53 q54 q55 q56

*Create labels for variables of interest
	*Demographics
recode q2 1=0 2=1, generate(Sex)
label variable Sex "Sex"
label define Sex 0 "Male" 1 "Female"
label values Sex Sex
sum Sex

destring q3, generate(Age) force
label variable Age "Age"

rename q4 Income
label variable Income "Income"
label define Income 1 "Less than $25,000" 2 "$25,000 to $49,999" 3 "$50,000 to $74,999" 4 "$75,000 to $99,999" 5 "$100,000 to $149,999" 6 "$150,000 to $199,999" 7 "$200,000 or more"
label values Income Income
sum Income

rename q5 Partisanship
label define Partisanship 1 "Democrat" 2 "Republican" 3 "Independent" 4 "Something else"
label values Partisanship Partisanship

rename q6 Ideology
label variable Ideology "Ideology"
label define Ideology 1 "Very Liberal" 2 "Liberal" 3 "Slightly Liberal" 4 "Moderate" 5 "Slightly Conservative" 6 "Conservative" 7 "Very Conservative"
label values Ideology Ideology
sum Ideology

rename q8 Education
label variable Education "Education"
label define Education 1 "Less than high school" 2 "High school graduate or GED" 3 "Some college but no degree (yet)" 4 "2-year college degree" 5 "4-year college degree" 6 "Post-graduate degree (MA, MBA, MD, JD, PhD, etc.)"
label values Education Education
sum Education



*Age variable contains two responses that represent impossible ages (117, 414). Convert to missing values.
mvdecode Age, mv(414)
mvdecode Age, mv(117)
sum Age


*Create dummy variables for Partisanship
recode Partisanship 1=1 2/4=0, gen(Democrat)
label variable Democrat "Democrat"
recode Partisanship 1=0 2=1 3=0 4=0, gen(Republican)
label variable Republican "Republican"
recode Partisanship 1=0 2=0 3=1 4=0, gen(Independent)
label variable Independent "Independent"
recode Partisanship 1=0 2=0 3=0 4=1, gen(Other_party)
label variable Other_party "Other party"
sum Democrat Republican Independent Other_party


*Create a new recoded variable for q5 Partisanship (continuous, low to high, with Indeps and Others combined)
recode Partisanship 1=1 2=3 3=2 4=2, generate(Partisanship_recoded)
label variable Partisanship_recoded "Partisan affiliation (continuous)"
label define Partisanship_recoded 1 "Democrat" 2 "Independents/Others" 3 "Republican" 
label values Partisanship_recoded Partisanship_recoded


*Create a new recoded variable for q7 (low to high) 
recode q7 1=5 2=4 3=3 4=2 5=1, generate(Follow_politics)
label variable Follow_politics "Follows politics"
label define Follow_politics 1 "Never" 2 "Hardly at all" 3 "Only now and then" 4 "Some of the time" 5 "Most of the time"
label values Follow_politics Follow_politics
sum Follow_politics


*Create a new recoded continuous variable for Trump Job Approval
recode q67 1=3 2=1 3=2, gen(Trump_approval)
label variable Trump_approval "Trump Job Approval"
sum Trump_approval


*Create 2 new recoded variables for q83, q85, and q87 (belief that Russia tried to interfere with 2016 election)
	*Variable showing each response for all participants
recode q83 1=3 2=1 3=2, gen(Rus_intfrd_1)
recode q85 1=3 2=1 3=2, gen(Rus_intfrd_2)
recode q87 1=3 2=1 3=2, gen(Rus_intfrd_3)
	*Combine Rus_intrd variables into one column
egen Rus_influence = rowtotal(Rus_intfrd_1 Rus_intfrd_2 Rus_intfrd_3)
label variable Rus_influence "Did Russia influence 2016 election?"
label define Rus_influence 1 "No" 2 "I don't know" 3 "Yes"
label values Rus_influence Rus_influence
	*Binary (yes/no) variable showing only whether response was "Yes" or combined "No/DK"
recode q83 1=1 2/3=0, gen(Rus_intfrd_YN_1)
recode q85 1=1 2/3=0, gen(Rus_intfrd_YN_2)
recode q87 1=1 2/3=0, gen(Rus_intfrd_YN_3)
	*Combine Rus_intrd_YN variables into one column
egen Rus_influence_YN = rowmax(Rus_intfrd_YN_1 Rus_intfrd_YN_2 Rus_intfrd_YN_3)
label variable Rus_influence_YN "Did Russia influence 2016 election (Y/N)?"
label define Rus_influence_YN 1 "Yes" 0 "No or Don't know"
label values Rus_influence_YN Rus_influence_YN
sum Rus_influence_YN

	
*Create a new recoded variable for q84 representing respondents' suspected reason that Russia tried to interfere (e.g., conspiracy, poor judgment, or standard campaign operating procedures)
clonevar Reason_1 = q84
clonevar Reason_2 = q86
clonevar Reason_3 = q88
	*Combine Reason variables into one column
egen Russia_reason = rowmax(Reason_1 Reason_2 Reason_3)
label variable Russia_reason "Reason you believe Trump campaign contacted Russia"
label define Russia_reason 1 "Poor judgment" 2 "Conspiracy to steal election" 3 "Standard campaign operating procedures"
label values Russia_reason Russia_reason

	
*Create a new binary variable for q84 representing yes/no belief that Trump-Russia contact indicated a conspiracy to steal the election.
recode q84 1=0 2=1 3=0, gen(Consp_1)
recode q86 1=0 2=1 3=0, gen(Consp_2)
recode q88 1=0 2=1 3=0, gen(Consp_3)
	*Combine Consp variables into one column
egen Conspiracy = rowmax(Consp_1 Consp_2 Consp_3)
label variable Conspiracy "Belief that Trump-Russia contact indicated conspiracy to steal 2016 election"
label define Conspiracy 1 "Yes" 0 "No"
label values Conspiracy Conspiracy
sum Conspiracy	
	
	
*Create Condition variable (categorical)
recode q83 1=1 2=1 3=1, gen(cond_consp)
recode q85 1=2 2=2 3=2, gen(cond_PJ)
recode q87 1=3 2=3 3=3, gen(cond_SOP)
	*Combine into 1 variable column
egen Condition = rowmax(cond_consp cond_PJ cond_SOP)
label variable Condition "Condition"
label define Condition 1 "Conspiracy" 2 "Poor judgment" 3 "Standard campaign operating procedures"
label values Condition Condition
	
	
*Conspiracy Thinking Scale
recode q53 1=5 2=4 3=3 4=2 5=1, gen(CTS_1)
recode q54 1=5 2=4 3=3 4=2 5=1, gen(CTS_2)
recode q55 1=5 2=4 3=3 4=2 5=1, gen(CTS_3)
recode q56 1=5 2=4 3=3 4=2 5=1, gen(CTS_4)
	*Check reliability and create an overall Conspiracy thinking variable
alpha CTS_1 CTS_2 CTS_3 CTS_4, gen(Consp_thinking)
label variable Consp_thinking "Conspiracy thinking"
sum Consp_thinking


*Generating frequency tables for main demographics variables
tab Sex
tab Income
tab Education
tab Partisanship
tab Partisanship_recoded
tab Trump_approval
tab Rus_influence
tab Rus_influence_YN
tab Conspiracy
tab Condition
tab Consp_thinking
tab Follow_politics
tab Ideology
tab Democrat
tab Republican
tab Independent
tab Other_party


*Correlations, means, and SDs for key study variables
summarize Consp_thinking Ideology Follow_politics Conspiracy Rus_influence Rus_influence_YN Trump_approval Partisanship_recoded Democrat Republican Independent Other_party Sex Age Income Education
pwcorr Consp_thinking Ideology Follow_politics Conspiracy Rus_influence_YN Trump_approval Democrat Republican Independent Other_party Sex Age Income Education, sig star(.05)
asdoc pwcorr Consp_thinking Ideology Follow_politics Conspiracy Rus_influence_YN Trump_approval Democrat Republican Independent Other_party Sex Age Income Education, sig star(.05)


*Chi-square tests of association
	*Test whether experimental treatment (informational cue) is sig. associated with beliefs about whether Russia attempted to influence 2016 election
tabulate Condition Rus_influence, cchi2 chi2 expected row
	*Test whether experimental treatment (informational cue) is sig. associated with reason respondents believed Russia attempted to influence 2016 election (conspiracy, poor judgment, SOP).
tabulate Condition Russia_reason, cchi2 chi2 expected row
		

*Regression models				
	*Binary logistic regression with Rus_influence_YN as the DV. 
		*Logistic gives odds ratio
		*Logit gives the coefficients
logistic Rus_influence_YN Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other 
logit Rus_influence_YN Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other

		*Generate some quick tables using "asdoc" package
asdoc logistic Rus_influence_YN Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other 
asdoc logit Rus_influence_YN Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other

	*Binary logistic regression with Conspiracy as the DV. 
		*Logistic gives odds ratio
		*Logit gives the coefficients
logistic Conspiracy Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other
logit Conspiracy Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other

		*Generate some quick tables using "asdoc" package
asdoc logistic Conspiracy Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other
asdoc logit Conspiracy Consp_thinking Ideology Follow_politics Trump_approval Sex Age Income Educ Democrat Republican Other

*save out replication data file
save "/Users/caseyklofstad/Library/CloudStorage/Dropbox/NSF Conspiracy Theory Surveys/casey 2018 survey/trump experiment paper/trump replication data.dta"

*END OF LINE
